package com.bibimaya.auto.mapper.dao.entity;

import com.bibimaya.auto.mapper.dao.annotation.NotEntity;
import com.bibimaya.auto.mapper.dao.utils.SqlSecurityUtil;

import java.io.Serializable;
import java.util.HashMap;

/**
 * BaseEntity
 * Created by lijianwei
 */
@NotEntity
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 非实体类参数传递查询
     */
    private transient HashMap<String, Object> ov;

    public boolean putOvParam(String key, Object obj){
        if(obj instanceof String){
            if(obj != null && !SqlSecurityUtil.isSecurity(obj.toString())){
                return false;
            }
        }
        if(ov == null) {
            synchronized (this) {
                if (ov == null)
                    ov = new HashMap<>();
            }
        }
        ov.put(key, obj);
        return true;
    }

    public void setSort(String sort){
        putOvParam("sortFields", sort);
    }

}
